package com.iwuke.dance.wallet.e_coin.adapter;

import android.content.Context;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.iwuke.dance.R;
import com.iwuke.dance.wallet.bean.ECoinTopUpBean;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;

/**
 * @author: 魏从响
 * @date: 2025/9/17
 */
public class ECoinTopUpAdapter extends BaseQuickAdapter<ECoinTopUpBean, BaseViewHolder> {

    private final Context context;
    private List<RelativeLayout> rlts = new ArrayList<>();
    private List<TextView> tvs = new ArrayList<>();


    public ECoinTopUpAdapter(Context context, int activityECoinTopUp, List<ECoinTopUpBean> list) {
        super(activityECoinTopUp, list);
        this.context = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, ECoinTopUpBean eCoinTopUpBean) {

        RelativeLayout rlt_item_e_coin_top_up = baseViewHolder.findView(R.id.rlt_item_e_coin_top_up);
        TextView tv_top_up_e_coin = baseViewHolder.findView(R.id.tv_top_up_e_coin);
        TextView tv_top_up_amount = baseViewHolder.findView(R.id.tv_top_up_amount);

        rlts.add(rlt_item_e_coin_top_up);
        tvs.add(tv_top_up_amount);

        if (getItemPosition(eCoinTopUpBean)==0){
            rlt_item_e_coin_top_up.setBackgroundResource(R.drawable.bg_radius6_color_5ed_f8_box_shape);
            tv_top_up_amount.setBackgroundResource(R.drawable.bg_bottom_radius6_color_5ed_shape);
            tv_top_up_amount.setTextColor(context.getColor(R.color.white));
        }

        tv_top_up_e_coin.setText(String.valueOf(eCoinTopUpBean.e_coin));
        tv_top_up_amount.setText("￥"+eCoinTopUpBean.top_up_amount);


    }

    public void setImgList(int position){
        for (int i=0;i<rlts.size();i++){
            if (position==i){
                rlts.get(i).setBackgroundResource(R.drawable.bg_radius6_color_5ed_f8_box_shape);
                tvs.get(i).setBackgroundResource(R.drawable.bg_bottom_radius6_color_5ed_shape);
                tvs.get(i).setTextColor(context.getColor(R.color.white));
            }else {
                rlts.get(i).setBackgroundResource(R.drawable.bg_radius6_color_db_f8_shape);
                tvs.get(i).setBackgroundResource(R.drawable.bg_radius6_color_db_shape);
                tvs.get(i).setTextColor(context.getColor(R.color.color_333));
            }
        }
    }

}
